<template>
  <div class="warningPanel">
    <h3>实时报警</h3>
    <div v-if="realTimeWarningPanel[0] && realTimeWarningPanel[0].length > 0">
      <el-carousel :height="(realTimeWarningPanel[0].length * 26) + 'px'" direction="vertical" :autoplay="true" indicator-position="none">
        <el-carousel-item v-for="(item, index) of realTimeWarningPanel" :key="index">
            <div class="warnItem" v-for="(line, cindex) of item" :key="cindex">
              {{line.station}}
              <el-tooltip :disabled="line.content.length < 10" :content="line.content" placement="top-start">
                <span class="warnText">{{line.content}}</span>
              </el-tooltip>
            </div>
        </el-carousel-item>
      </el-carousel>
    </div>
    <div v-else>
      <p style="color: #c94242;">暂无消息</p>
    </div>

  </div>
</template>

<script>
import { mapGetters, mapActions } from 'vuex'
export default {
  name: 'mapStatistics',
  data () {
    return {}
  },
  methods: {
    ...mapActions([
      'fetchRealTimeWarning'
    ]),
  },
  async created() {
    await this.fetchRealTimeWarning()
  },
  computed: {
    ...mapGetters({
      realTimeWarningPanel: 'getRealTimeWarningPanel',
    })
  },
  
}
</script>
<style scoped>
.warningPanel {
  position: absolute;
  left: 20px;
  bottom: 20px;
  padding: 13px;
  z-index: 3;
  min-width: 220px;
  border-top: 2px solid #0a85fa;
  background: #ffffff;
  box-shadow: 0px 0px 6px 0px 
		rgba(174, 174, 174, 0.14);

}
.warningPanel h3 {
  margin-bottom: 12px;
}
.warningPanel .warnItem {
  color: #909090;
  line-height: 26px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.warningPanel .warnItem .warnText {
  display: inline-block;
  width: 0;
  color: #c94242;
  margin: 0 4px;
}
.warningPanel .warnItem::before {
  content: '>';
  margin-right: 5px;
}

</style>
